import React, {PureComponent} from 'react';
import SplashScreen from 'react-native-splash-screen'
import { RNStorage } from '../common/Storage/AppStorage';
import Utils from '../libs/Utils';
import DataCenter from '../logic/DataCenter';
import MainLogicLoop from '../logic/Main';

export default class WelcomePage extends PureComponent {

    constructor(props) {
        super(props);
        this.init();
    }

    init = async () => {
        DataCenter.machineIp = await Utils.getMachineIp();
        MainLogicLoop.startLogic();
        setTimeout(()=>{
            SplashScreen.hide();
            const{navigation} = this.props;
            if(RNStorage.registerInfo) {
                navigation.replace("Main");
            } else {
                navigation.replace("RegisterDevice");
            }
            
        }, 2500);
    };

    render() {
        return null;
    }
}

